"""
@author: peng
@email: sb.peng@hzgosun.com
@file: electricFencePage.py
@time: 2019/5/23 11:41

"""
from common.poium.poium import Page
from common.vue.button import VueButton
from common.vue.element import VueElements
from common.vue.float_window import FloatWindow
from common.vue.label import ElementType as ET, ElementBaseLabel
from common.vue.region import VueRegion
from common.vue.search import VueSearch
from common.vue.table import VueTable, VueTurnPage
from common.vue.tree import VueTree

class SearchTools(VueSearch):
    """序列号查询"""
    NumberWord_input = ElementBaseLabel(ET.INPUT, label="序列号")  # 序列号后面的输入框
    region_region_input = ElementBaseLabel(ET.REGION, label="区域")  # 区域后面的区域请选择框
    region_region_selector = VueRegion(index=0)  # region_dropdown_list选择区域时，点击region_input出现的
    community_dropdown_list = ElementBaseLabel(ET.DROPDOWN_LIST, label="小区")  # 小区请选择框
    commnity_community_selector = VueRegion(index=0)

    search_btn = VueButton("检索")  # 查询按钮

    def __init__(self):
        """
        首先找到search的父类（比如是类A），然后把类search的对象self转换为类A的对象，
        然后“被转换”的类A对象调用自己的__init__函数
        """
        super(SearchTools, self).__init__()


class Table(VueTable):
    """banner列表"""
    add_btn = VueButton("添加")
    import_btn = VueButton('导入')

    def __init__(self):
        super(Table, self).__init__()


class AddFenceWindow(FloatWindow):
    """添加电围弹窗"""
    add_fenceName = ElementBaseLabel(ET.INPUT, label="电围名称")
    add_fenceNumber = ElementBaseLabel(ET.INPUT, label="序列号")
    add_fenceStyle = ElementBaseLabel(ET.DROPDOWN_LIST, label="厂商类型")
    add_equipFence= ElementBaseLabel(ET.DROPDOWN_LIST, label="设备类型")
    add_FenceRegion= ElementBaseLabel(ET.REGION,label="区域")
    add_FenceRegion_selector = VueRegion(index=1)
    add_FenceCommunity = ElementBaseLabel(ET.DROPDOWN_LIST,"小区")
    add_FenceIp = ElementBaseLabel(ET.INPUT,label="电围IP")


    def __init__(self, title=None, index=None):
        super(AddFenceWindow, self).__init__(title=title, index=index)


class ImportFenceWindow(AddFenceWindow):
    '''导入电围'''
    view_btn = VueButton("浏览")
    import_ = VueButton("导入")
    option_xlsx = ElementBaseLabel(ET.UPLOAD, label="选择EXCEL文档")
    shut_down = VueButton("关闭")

    def __init__(self,title=None,index=None):
        super(ImportFenceWindow,self).__init__(index=index , title=title)


class ModifyFenceWindow(AddFenceWindow):
    '''修改电围'''
    change_btn = VueButton("修改")

    def __init__(self,title=None, index = None):
        super(ModifyFenceWindow, self).__init__(index=index, title=title)


class MakeSureWindow(AddFenceWindow):
    '''修改电围'''

    def __init__(self,title=None, index = None):
        super(MakeSureWindow, self).__init__(index=index, title=title)


class ElectricFencePage(Page):
    """电子围栏管理页面"""
    searchTools = SearchTools()
    addFence = AddFenceWindow(title= '添加电围')
    modifyFence = ModifyFenceWindow(title="电围详情")
    importFence = ImportFenceWindow(title = "导入")
    turnPage = VueTurnPage()
    table = Table()
    makeSure = MakeSureWindow(title="删除确认")



